<template>
  <div>
    <el-dialog :model-value="visible" :width="width + 'px'" :before-close="onClose" :show-close="false">
      <template #header="{ close, titleId, titleClass }">
        <div class="my-header">
          <h4 :id="titleId" :class="titleClass">{{ title }}</h4>
          <el-button type="danger" @click="close">
            <el-icon class="el-icon--left">
              <CircleCloseFilled />
            </el-icon>
            Close
          </el-button>
        </div>
      </template>
      <div class="container" :style="{ height: height + 'px' }">
        <slot name="content"></slot>
      </div>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="onClose">取消</el-button>
          <el-button type="primary" @click="onConfirm">
            确认
          </el-button>
        </span>
      </template>
    </el-dialog>
  </div>
</template>

<script setup>
import { defineProps, defineEmits, watch, onMounted } from 'vue';
import { ElButton, ElDialog } from 'element-plus'
import { CircleCloseFilled } from '@element-plus/icons-vue'
const props = defineProps({
  title: {
    type: String,
    default: "标题",
  },
  visible: {
    type: Boolean,
    default: false,
  },
  width: {
    type: Number,
    default: 450,
  },
  height: {
    type: Number,
    default: 250,
  }
})
const emit = defineEmits(['onClose,onConfirm'])

const onConfirm = () => {
  emit('onConfirm')
}
const onClose = () => {
  emit('onClose')
}
// 打开事件回调函数
onMounted(() => {
  console.log(props.width);
})


</script>

<style lang="scss" scoped>
.container {
  overflow-x: initial;
  overflow-y: auto;
}

:deep(button:focus) {
  outline: none;
}

:deep(.el-dialog__header) {
  margin-right: 0;
  background-color: var(--el-color-primary);
  line-height: 40px;
}

.my-header {
  height: 40px;
  line-height: 40px;
  align-items: center;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  color: #fff;
}

:deep(.el-dialog__title) {
  color: #fff;
}
</style>